<?php session_start();
include("authentication.php");
require_once('../includes/conn.php'); 
require_once('../includes/settings.inc.php');
include("../includes/functions_emagineit.php");
$obj = new EmagineIT();

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if($_POST["publish"]) $publish = 1;
else $publish = 0;

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) 
{
	if(isset($_POST['new_page']) && $_POST['new_page'] =="Add New Page")
	{
		
			$_POST['page_physical_name'] = str_replace(" ","-",strtolower(trim($_POST['page_physical_name']))).".htm";
			if($_POST['robots'] == "noindex,nofollow") $_POST['robots'] = "noindex,nofollow";
			else $_POST['robots'] = "index,follow";
			if($_REQUEST["left"] == "on")
			{
				$left = "1";
			}
			else
			{
				$left = "0";
			}
			if($_REQUEST["footer"] == "on")
			{
				$footer = "1";
			}
			else
			{
				$footer = "0";
			}
			if($_REQUEST["have_child_pages"] == "on")
			{
				$have_child_pages = "1";
			}
			else
			{
				$have_child_pages = "0";
			}
			
			
			
			
			$target_path = "../images/";
			 $ts=time();
			 $header_image = "";
			 if($_FILES['header_image']['name'] != "")
			 {
				$target_path = $target_path .$ts. basename($_FILES['header_image']['name']);
				if(move_uploaded_file($_FILES['header_image']['tmp_name'], $target_path)) 
				{ 
					$header_image=$ts. basename( $_FILES['header_image']['name']);
				}
			 }
			
				  $s1_max_orderid = "select max(orderid) as orderid from contents where 1";
				 $q1_max_orderid = mysql_query($s1_max_orderid) or die($s1_max_orderid);
				 $r1_max_orderid = mysql_fetch_array($q1_max_orderid);
				 $orderid = $r1_max_orderid["orderid"] + 1;
				 
				$SQL = "insert into contents set content_title = '".$_REQUEST['child_content_title']."' ,content_desc = '".$_REQUEST["child_content_desc"]."',title = '".$_REQUEST["content_type"]."',description = '".$_REQUEST["description"]."',keywords = '".$_REQUEST["keywords"]."',author = '".$_REQUEST["author"]."',robots = '".$_REQUEST["robots"]."',copyright = '".$_REQUEST["copyright"]."',show_on_footer = '".$footer."',show_on_sitemap = '".$left."',page_physical_name = '".$_POST['page_physical_name']."',page_create_date = '".date('Y-m-d h:i:s')."',orderid = '".$orderid."',parent_id = '".$_REQUEST["child_content_id"]."',header_image = '".$header_image."', google_analytics = '".$_REQUEST["google_analytics"]."',header_image_title='".$_REQUEST['header_image_title']."',header_image_text = '".$_REQUEST["header_image_text"]."',have_child_pages='".$have_child_pages."'";
				$Result1 = mysql_query($SQL) or die($SQL);
				 if($_REQUEST["header_image_default"] == 'on')
				{
						$s1_updt_default_image = "update child_contents set header_image_default = 0 where 1";
						$q1_updt_default_image = mysql_query($s1_updt_default_image) or die($s1_updt_default_image);
						
						$s2_updt_default_image = "update child_contents set header_image_default = 1 where 1 and child_id = '".mysql_insert_id()."'";
						$q2_updt_default_image = mysql_query($s2_updt_default_image) or die($s2_updt_default_image);	
					}
		
	/*	else
		if($_REQUEST["language"] == 'ja')
		{
			$_POST['page_physical_name_ja'] = str_replace(" ","-",strtolower(trim($_POST['page_physical_name_ja']))).".htm";
			if($_POST['robots_ja'] == "noindex,nofollow") $_POST['robots_ja'] = "noindex,nofollow";
			else $_POST['robots_ja'] = "index,follow";
			if($_REQUEST["left_ja"] == "on")
			{
				$left = "1";
			}
			else
			{
				$left = "0";
			}
			if($_REQUEST["footer_ja"] == "on")
			{
				$footer = "1";
			}
			else
			{
				$footer = "0";
			}
			if($_REQUEST["have_child_pages"] == "on")
			{
				$have_child_pages = "1";
			}
			else
			{
				$have_child_pages = "0";
			}
			
			
			
			$target_path = "../images/";
			 $ts=time();
			 $header_image = "";
			 if($_FILES['header_image_ja']['name'] != "")
			 {
				$target_path = $target_path .$ts. basename($_FILES['header_image_ja']['name']);
				if(move_uploaded_file($_FILES['header_image_ja']['tmp_name'], $target_path)) 
				{ 
					$header_image=$ts. basename( $_FILES['header_image_ja']['name']);
				}
			 }
				 $s1_max_orderid = "select max(orderid) as orderid from child_contents where 1";
				 $q1_max_orderid = mysql_query($s1_max_orderid) or die($s1_max_orderid);
				 $r1_max_orderid = mysql_fetch_array($q1_max_orderid);
				 $orderid = $r1_max_orderid["orderid"] + 1;
				$SQL = "insert into child_contents set child_content_title_ja = '".$_REQUEST['child_content_title_ja']."' ,child_content_desc_ja = '".$_REQUEST["child_content_desc_ja"]."',title_ja = '".$_REQUEST["child_content_type_ja"]."',description_ja = '".$_REQUEST["description_ja"]."',keywords_ja = '".$_REQUEST["keywords_ja"]."',author_ja = '".$_REQUEST["author_ja"]."',robots = '".$_REQUEST["robots_ja"]."',copyright_ja = '".$_REQUEST["copyright_ja"]."',show_on_footer = '".$footer."',show_on_sitemap = '".$left."',page_physical_name = '".$_POST['page_physical_name_ja']."',page_create_date = '".date('Y-m-d h:i:s')."',orderid = '".$orderid."',child_content_id = '".$_REQUEST["child_content_id_ja"]."',header_image = '".$header_image."', google_analytics = '".$_REQUEST["google_analytics_ja"]."',header_image_text_ja = '".$_REQUEST["header_image_text_ja"]."'";
				$Result1 = mysql_query($SQL) or die($SQL);
				if($_REQUEST["header_image_default_ja"] == 'on')
				{
						$s1_updt_default_image = "update child_contents set header_image_default = 0 where 1";
						$q1_updt_default_image = mysql_query($s1_updt_default_image) or die($s1_updt_default_image);
						
						$s2_updt_default_image = "update child_contents set header_image_default = 1 where 1 and child_id = '".mysql_insert_id()."'";
						$q2_updt_default_image = mysql_query($s2_updt_default_image) or die($s2_updt_default_image);	
					}
		}*/
		
	}
	else
	{
			
				$_POST['page_physical_name'] = str_replace(" ","-",strtolower(trim($_POST['page_physical_name']))).".htm";
				if($_POST['robots'] == "noindex,nofollow") $_POST['robots'] = "noindex,nofollow";
				else $_POST['robots'] = "index,follow";
				if($_REQUEST["left"] == "on")
				{
					$left = "1";
				}
				else
				{
					$left = "0";
				}
				if($_REQUEST["footer"] == "on")
				{
					$footer = "1";
				}
				else
				{
					$footer = "0";
				}
				if($_REQUEST["have_child_pages"] == "on")
			{
				$have_child_pages = "1";
			}
			else
			{
				$have_child_pages = "0";
			}
				
				
					 $s1_max_orderid = "select max(orderid) as orderid from contents where 1";
				 $q1_max_orderid = mysql_query($s1_max_orderid) or die($s1_max_orderid);
				 $r1_max_orderid = mysql_fetch_array($q1_max_orderid);
				 $orderid = $r1_max_orderid["orderid"] + 1;
					 
					 $target_path = "../images/";
					 $ts=time();
					 $products_picture = "";
					 if($_FILES['header_image']['name'] != "")
					 {
						$qr_image="select header_image from contents where id = '".$_REQUEST["code"]."'";
						$result_image=mysql_query($qr_image) or die($qr_image);
						$row_image=mysql_fetch_array($result_image);
						$img_path="../images/".$row_image["header_image"];	
						if(is_file("$img_path"))
						{
						   unlink("$img_path"); 
						}
						$target_path = $target_path .$ts. basename($_FILES['header_image']['name']);
						if(move_uploaded_file($_FILES['header_image']['tmp_name'], $target_path)) 
						{ 
							$products_picture=$ts. basename( $_FILES['header_image']['name']);
						}
						$SQL1 ="update `contents` set `header_image` = '".$products_picture."' where id = '".$_REQUEST["code"]."'";
						$Result2 = mysql_query($SQL1) or die($SQL1);
					 }
					 
					 if($_REQUEST["header_image_default"] == 'on')
					 {
						$s1_updt_default_image = "update contents set header_image_default = 0 where 1";
						$q1_updt_default_image = mysql_query($s1_updt_default_image) or die($s1_updt_default_image);
						
						$s2_updt_default_image = "update contents set header_image_default = 1 where 1 and id = '".$_REQUEST["code"]."'";
						$q2_updt_default_image = mysql_query($s2_updt_default_image) or die($s2_updt_default_image);	
					 }
					 
					$SQL = "UPDATE contents set content_title = '".$_REQUEST['child_content_title']."' ,content_desc = '".$_REQUEST["child_content_desc"]."',title = '".$_REQUEST["content_type"]."',description = '".$_REQUEST["description"]."',keywords = '".$_REQUEST["keywords"]."',author = '".$_REQUEST["author"]."',robots = '".$_REQUEST["robots"]."',copyright = '".$_REQUEST["copyright"]."',show_on_footer = '".$footer."',show_on_sitemap = '".$left."',page_physical_name = '".$_POST['page_physical_name']."',parent_id = '".$_REQUEST["child_content_id"]."', google_analytics = '".$_REQUEST["google_analytics"]."',header_image_title='".$_REQUEST['header_image_title']."',header_image_text = '".$_REQUEST["header_image_text"]."',have_child_pages='".$have_child_pages."' where id = '".$_REQUEST["code"]."'";
					$Result1 = mysql_query($SQL) or die($SQL);
			
			
			
	}
	 //$Result1 = mysql_query($SQL) or die($SQL);
	  if(!$Result1)
	   $msg = "Error: ".mysql_error()." - ".mysql_errno();
	  else
	  { 
		  $insertGoTo = "contents.php";
		  if (isset($_SERVER['QUERY_STRING'])) {
			$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
			$insertGoTo .= $_SERVER['QUERY_STRING'];
		  }
	  echo "<script language='javascript'>
			alert('Page saved successfully!');
			window.location = '".$_SERVER['HTTP_REFERER']."';
			</script>";  	
		//header(sprintf("Location: %s", $insertGoTo));
	  }//END ELSE
}

// For data retrieval
$s1 = "select * from contents where id = '".$_REQUEST["code"]."'";
$q1 = mysql_query($s1) or die($s1);
$row_sel = mysql_fetch_array($q1); 
include("fckeditor/fckeditor.php") ;	
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$site_name?> - Admin Panel</title>
<META NAME="ROBOTS" CONTENT="NOARCHIVE">
<META NAME="ROBOTS" CONTENT="NOINDEX">
<META NAME="ROBOTS" CONTENT="NOIMAGEINDEX">
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
	// <![CDATA[
	var myMenu;
	window.onload = function() {
		myMenu = new SDMenu("my_menu");
		myMenu.init();
	};
	// ]]>
	function change_status(type)
	{
		if(type == '1')
		{
			document.getElementById("email_details").style.display = 'inline';
		}
		else
		if(type == '0')
		{
			document.getElementById("email_details").style.display = 'none';
		}
	}
</script>
<script type="text/javascript" src="sdmenu/sdmenu.js"></script>
<script language="javascript" type="text/javascript" src="../includes/validate.js"></script>
<script type="text/javascript" src="<?=$path?>js/jsapi.js"></script>
<link href="css/styleer.css" rel="stylesheet" type="text/css">
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
<link href="<?=$path?>css/viterumCSS.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?=$path?>js/globale_jsfile.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function change_language(typ)
{
	//alert(typ);
	if(typ == 'show_en')
	{
		document.getElementById("show_ja").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_en').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'en';
	}
	else
	if(typ == 'show_ja')
	{
		document.getElementById("show_ja").style.display = "none";
		document.getElementById("show_en").style.display = "none";
		document.getElementById("main_body_ajax_show_post_top").style.display = "inline";
		setTimeout("document.getElementById('main_body_ajax_show_post_top').style.display = 'none';", 2000);
		setTimeout("document.getElementById('show_ja').style.display = 'inline';", 2000);
		document.getElementById("language").value = 'ja';
	}
	//alert(document.getElementById("language").value);
}
</script>
</head>
<body >
<table width="987" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="987"><img src="<?=$path?>images/spacer.gif" width="100" height="25" /></td>
  </tr>
  <tr>
    <td><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="<?=$path?>images/index_03.gif" width="46" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_04.gif" width="895" height="57" alt="" /></td>
        <td><img src="<?=$path?>images/index_05.gif" width="46" height="57" alt="" /></td>
      </tr>
      <tr>
        <td background="<?=$path?>images/index_07.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>&nbsp;</td>
          </tr>
      
      <tr>
        <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="16%" valign="top"><table width="80%"  border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><table width="80%"  border="0" cellspacing="0" cellpadding="0">
                      
                      <tr>
                        <td valign="top"><?php include("leftnavigation.php");?></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td height="6"><img src="images/spacer.gif" width="1" height="1"></td>
                  </tr>
                  
                  
                </table></td>
                <td width="84%" valign="top"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="233" valign="top" class="blueBarborder2"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
					
                      <tr>
                        <td height="31" class="blueBarborder"><table width="97%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td class="blackTxt"><?=$site_name?> - Admin Panel </td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="202" valign="top" bgcolor="#dbedf1"><table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="8"><img src="images/spacer.gif" width="1" height="1"></td>
                          </tr>
                          <tr>
                            <td>
<?php
if(isset($include_page) && $include_page !=NULL)
 include($include_page);
else
{ 
?>			<form name="RTEDemo" action="<?php echo $editFormAction; ?>" method="post" onSubmit="return submitForm();" enctype="multipart/form-data">				
			<table width="100%" align="left" cellpadding="0" cellspacing="0">
                                <tr valign="baseline">
                                  <td colspan="3" align="center" nowrap class="Redsmalltext">
								  <strong><?php echo $msg?></strong></td></tr>
								 
								  <tr><td colspan="3" valign="top"><div id="show_en"><table width="100%" border="0" cellspacing="0" cellpadding="0">
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Page Name:</strong></td>
                                  <td colspan="2">
<input type="text" name="page_physical_name" id="page_physical_name" value="<?php echo $_POST['page_physical_name']?$_POST['page_physical_name']:str_replace(".htm","",$row_sel['page_physical_name']);?>" size="45" maxlength="255"><span>.htm</span>                                  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="117" align="left" nowrap class="smalltext"><strong>Header Image : </strong></td>
                                  <td colspan="2">
<? 			if(is_file("../images/".$row_sel["header_image"]))
			{
			$b=end(explode('.',$row_sel["header_image"]));
			if($b == 'swf')
			{
			?>
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="400">
              <param name="movie" value="<?=$path?>images/<?=$row_sel["header_image"]?>" />
              <param name="quality" value="high" /><param name="wmode" value="transparent" />
              <embed src="<?=$path?>images/<?=$row_sel["header_image"]?>" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  type="application/x-shockwave-flash" width="400"></embed>
			  </object>
			  <br />
			  <?
			  }
			  else
			  {?>
			  <img src="<?=$path?>images/<?=$row_sel["header_image"]?>" width="400"/> <br />
			  <?
			  }
			   }?><input id="header_image" name="header_image" type="file" class="txtField1" size="48"/>&nbsp;&nbsp;<span class="smalltext">Make it default:</span>&nbsp;<input type="checkbox" name="header_image_default" id="header_image_default" <?=$row_sel["header_image_default"]==1?"checked=checked":""?> /></td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  
								  
								  
								    <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Header Image Title : </strong></td>
                                  <td colspan="2">
<input type="text" name="header_image_title" value="<?php echo $_POST['header_image_title']?$_POST['header_image_title']:$row_sel['header_image_title'];?>" size="45">                                  </td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr> 
								  
								  
								  
								  <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext" valign="top"><strong>Header Image Text : </strong></td>
                                  <td colspan="2"><textarea type="text" name="header_image_text" rows="5" cols="62"><?=$_POST['header_image_text']?$_POST['header_image_text']:$row_sel['header_image_text']?></textarea></td>
                                </tr>
								  
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								
								 
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Child Page of : </strong></td>
                                  <td colspan="2">
<select name="child_content_id" id="child_content_id" style="width:310px;">
<?
		$r1_power = "select * from contents where 1 and have_child_pages=1 order by orderid";
		$q1_power = mysql_query($r1_power) or die($r1_power);
		while($r1_power = mysql_fetch_array($q1_power))
		{
			if($_REQUEST["for"] == $r1_power["id"])
			{
		?>
		<option value="<?=$r1_power["id"]?>" selected="selected"><?=$r1_power["content_title"]?></option>
		<?
			}
			else
			if($row_sel["parent_id"] == $r1_power["id"])
			{
		?>
		<option value="<?=$r1_power["id"]?>" selected="selected"><?=$r1_power["content_title"]?></option>
		<?
			}
			else
			{
			?>
		<option value="<?=$r1_power["id"]?>"><?=$r1_power["content_title"]?></option>
		<?
			}
		}
?>

</select>                                  </td>
                                </tr>
   								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Content Title : </strong></td>
                                  <td colspan="2">
<input type="text" name="child_content_title" value="<?php echo $_POST['child_content_title']?$_POST['child_content_title']:$row_sel['content_title'];?>" size="45" onKeyUp="keyup(this,'txttitle');">                                  </td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>                                 
                                <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>Title : </strong></td>
                                  <td colspan="2">
<input type="text" name="content_type" value="<?php echo $_POST['title']?$_POST['title']:$row_sel['title'];?>" size="45" onKeyUp="keyup(this,'txttitle');">                                  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td align="right" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td align="left" valign="top" nowrap class="smalltext" colspan="2"><span class="Redsmalltext">&gt;&gt;</span> Show On SiteMap
                                    <input type="checkbox" name="left" id="left" <?=$row_sel['show_on_sitemap']==1?"checked=checked":""?>>
									
									<span class="Redsmalltext">&gt;&gt;</span> Show on Footer&nbsp;&nbsp;
                                    <input type="checkbox" name="footer" id="footer" <?=$row_sel['show_on_footer']==1?"checked=checked":""?>>
									
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="Redsmalltext">&gt;&gt;</span> Have Child Pages
                                    <input type="checkbox" name="have_child_pages" id="have_child_pages" <?=$row_sel['have_child_pages']==1?"checked=checked":""?>>			
									
									
									</td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                 <td>&nbsp;</td>
                                  <td align="left" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span> Description for Site Map and Meta Tags<br>
                                    <textarea name="description" cols="32" rows="5" id="description"><?php echo $_POST['description']?$_POST['description']:$row_sel['description'];?></textarea></td>
                                  <td align="left" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span> Keywords for this page<br>
                                    <textarea name="keywords" cols="22" rows="5" id="keywords"><?php echo $_POST['keywords']?$_POST['keywords']:$row_sel['keywords']?></textarea></td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext"><strong>Robots : </strong></td>
                                  </tr>
                                <tr valign="baseline">
                                  <td align="right" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top" nowrap class="smalltext"><b>Index</b>&nbsp;
                                    <input   <?php if (!(strcmp($row_sel['robots'],"index,nofollow"))) {echo "checked=\"checked\"";} ?> name="robots" type="radio" value="index, nofollow" />&nbsp;&nbsp;&nbsp;&nbsp;<b>Follow</b>&nbsp;<input   <?php if (!(strcmp($row_sel['robots'],"noindex,follow"))) {echo "checked=\"checked\"";} ?> name="robots" type="radio" value="noindex,follow" />&nbsp;&nbsp;&nbsp;&nbsp;<b>Disallow</b>&nbsp;<input  <?php if (!(strcmp($row_sel['robots'],"noindex,nofollow"))) {echo "checked=\"checked\"";} ?> name="robots" type="radio" value="noindex,nofollow" />&nbsp;&nbsp;&nbsp;&nbsp;<b>Allow</b>&nbsp;<input  <?php if (!(strcmp($row_sel['robots'],"index,follow"))) {echo "checked=\"checked\"";} ?> name="robots" type="radio" value="index,follow" /></td>
  </tr>
</table>
</td>
                                 
                                </tr>
								
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext"><strong>Content text : </strong></td>
                                  </tr>
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="center" valign="top" nowrap class="smalltext">
                                    <?php
//format content for preloading
if (!(isset($_POST["child_content_desc"]))) {
	//$content = "here's the " . chr(13) . "\"preloaded <b>content</b>\"";
	$content = $row_sel['content_desc'];
} else {
	//retrieve posted value
	$content = $_POST["child_content_desc"];
}

// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// $oFCKeditor->BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
//$sBasePath = $_SERVER['PHP_SELF'] ;
//$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;

$oFCKeditor = new FCKeditor('child_content_desc') ;
$oFCKeditor->BasePath	= "fckeditor/" ;
//$oFCKeditor->Width		= "700" ;
$oFCKeditor->Height		= 700 ;
$oFCKeditor->Value		= $content ;
$oFCKeditor->Create() ;
?>									</td>
                                  </tr>
								  
                               <tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext" valign="top"><strong>Google Analytics : </strong></td>
                                  <td colspan="2"><textarea type="text" name="google_analytics" rows="5" cols="62"><?=$_POST['google_analytics']?$_POST['google_analytics']:$row_sel['google_analytics']?></textarea></td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext"><strong>Author : </strong></td>
                                  <td colspan="2"><input type="text" name="author" value="<?php echo $_POST['author']?$_POST['author']:$row_sel['author'];?>" size="32"></td>
                                </tr>
								<tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext"><strong>Copyright : </strong></td>
                                  <td colspan="2"><input type="text" name="copyright" value="<?php echo $_POST['copyright']?$_POST['copyright']:$row_sel['copyright'];?>" size="32"></td>
                                </tr>
								
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
</table></div><div id="show_ja" style="display:none;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext">&#12506;&#12540;&#12472;&#21517;&#65306; </td>
                                  <td colspan="2">
<input type="text" name="page_physical_name_ja" id="page_physical_name_ja" value="<?php echo $_POST['page_physical_name_ja']?$_POST['page_physical_name_ja']:str_replace(".htm","",$row_sel['page_physical_name']);?>" size="45" maxlength="255"><span>.htm</span>                                  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="117" align="left" nowrap class="smalltext">&#12504;&#12483;&#12480;&#12540;&#30011;&#20687;&#65306; </td>
                                  <td colspan="2">
<? 			if(is_file("../images/".$row_sel["header_image"]))
			{
			$b=end(explode('.',$row_sel["header_image"]));
			if($b == 'swf')
			{
			?>
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="400">
              <param name="movie" value="<?=$path?>images/<?=$row_sel["header_image"]?>" />
              <param name="quality" value="high" /><param name="wmode" value="transparent" />
              <embed src="<?=$path?>images/<?=$row_sel["header_image"]?>" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  type="application/x-shockwave-flash" width="400"></embed>
			  </object>
			  <br />
			  <?
			  }
			  else
			  {?>
			  <img src="<?=$path?>images/<?=$row_sel["header_image"]?>" width="400"/> <br />
			  <?
			  }
			   }?><input id="header_image_ja" name="header_image_ja" type="file" class="txtField1" size="48"/>&nbsp;&nbsp;&#12487;&#12501;&#12457;&#12523;&#12488;&#12434;&#30906;&#35469;&#65306;&nbsp;
			  <input type="checkbox" name="header_image_default_ja" id="header_image_default_ja" <?=$row_sel["header_image_default"]==1?"checked=checked":""?> /></td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
							
								   <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext"><strong>&#12504;&#12483;&#12480;&#30011;&#20687;&#12486;&#12461;&#12473;&#12488;&#65306; </strong></td>
                                  <td colspan="2">
<input type="text" name="header_image_text_ja" value="<?php echo $_POST['header_image_text_ja']?$_POST['header_image_text_ja']:$row_sel['header_image_text_ja'];?>" size="45">                                  </td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr> 
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext">&#23376;&#20379;&#12398;&#12506;&#12540;&#12472;&#65306; </td>
                                  <td colspan="2">
<select name="child_content_id_ja" id="child_content_id_ja" style="width:310px;">
<?
		$r1_power = "select * from contents where 1 and id between 2 and 6 and id <> 3 order by orderid";
		$q1_power = mysql_query($r1_power) or die($r1_power);
		while($r1_power = mysql_fetch_array($q1_power))
		{
			if($_REQUEST["for"] == $r1_power["id"])
			{
		?>
		<option value="<?=$r1_power["id"]?>" selected="selected"><?=$r1_power["content_title"]?></option>
		<?
			}
			else
			if($row_sel["child_content_id"] == $r1_power["id"])
			{
		?>
		<option value="<?=$r1_power["id"]?>" selected="selected"><?=$r1_power["content_title"]?></option>
		<?
			}
			else
			{
			?>
		<option value="<?=$r1_power["id"]?>"><?=$r1_power["content_title"]?></option>
		<?
			}
		}
?>

</select>                                  </td>
                                </tr>
   								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
								  <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext">&#12467;&#12531;&#12486;&#12531;&#12484;&#12398;&#12479;&#12452;&#12488;&#12523;&#65306;</td>
                                  <td colspan="2">
<input type="text" name="child_content_title_ja" value="<?php echo $_POST['child_content_title_ja']?$_POST['child_content_title_ja']:$row_sel['child_content_title_ja'];?>" size="45">                                  </td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>                                 
                                <tr valign="baseline">
                                  <td width="141" align="left" nowrap class="smalltext">&#12479;&#12452;&#12488;&#12523;&#65306; </td>
                                  <td colspan="2">
<input type="text" name="content_type_ja" value="<?php echo $_POST['title_ja']?$_POST['title_ja']:$row_sel['title_ja'];?>" size="45">                                  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td align="right" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td align="left" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span>&#22320;&#22259;&#12434;&#34920;&#31034;&#12469;&#12452;&#12488;&#12510;&#12483;&#12503;&#12395;
  <input type="checkbox" name="left_ja" id="left_ja" <?=$row_sel['show_on_sitemap']==1?"checked=checked":""?>></td><td align="left" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span>&#22320;&#22259;&#12434;&#34920;&#31034;&#12501;&#12483;&#12479;&#12540;]  &nbsp;&nbsp;
                                    <input type="checkbox" name="footer_ja" id="footer_ja" <?=$row_sel['show_on_footer']==1?"checked=checked":""?>></td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                 
                                  <td align="left" colspan="2" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span> &#27010;&#35201;&#12469;&#12452;&#12488;&#12510;&#12483;&#12503;&#12420;&#12513;&#12479;&#12479;&#12464;&#12398;<br>
                                    <textarea name="description_ja" cols="32" rows="5" id="description_ja"><?php echo $_POST['description_ja']?$_POST['description_ja']:$row_sel['description_ja'];?></textarea></td>
                                  <td align="left" valign="top" nowrap class="smalltext"><span class="Redsmalltext">&gt;&gt;</span>&#12371;&#12398;&#12506;&#12540;&#12472;&#12398;&#12461;&#12540;&#12527;&#12540;&#12489; <br>
                                    <textarea name="keywords_ja" cols="22" rows="5" id="keywords_ja"><?php echo $_POST['keywords_ja']?$_POST['keywords_ja']:$row_sel['keywords_ja']?></textarea></td>
                                </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&#12525;&#12508;&#12483;&#12488;&#65306; </td>
                                  </tr>
                                <tr valign="baseline">
                                  <td align="right" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top" nowrap class="smalltext">&#30446;&#27425;
  <input   <?php if (!(strcmp($row_sel['robots'],"index,nofollow"))) {echo "checked=\"checked\"";} ?> name="robots_ja" type="radio" value="index,nofollow" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &#12316;&#12395;&#24467;&#12358;  &nbsp;&nbsp;
  <input   <?php if (!(strcmp($row_sel['robots'],"noindex,follow"))) {echo "checked=\"checked\"";} ?> name="robots_ja" type="radio" value="noindex,follow" />&nbsp;&nbsp;&nbsp;&nbsp;  &#35377;&#21487;&#12375;&#12394;&#12356;  &nbsp;
  <input  <?php if (!(strcmp($row_sel['robots'],"noindex,nofollow"))) {echo "checked=\"checked\"";} ?> name="robots_ja" type="radio" value="noindex,nofollow" />&nbsp;&nbsp;&nbsp;&nbsp;  &#35377;&#21487;&#12377;&#12427;
  <input  <?php if (!(strcmp($row_sel['robots'],"index,follow"))) {echo "checked=\"checked\"";} ?> name="robots_ja" type="radio" value="index,follow" /></td></tr>
</table>
</td>
                                 
                                </tr>
								
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&#12467;&#12531;&#12486;&#12531;&#12484;&#12398;&#12486;&#12461; </td>
                                  </tr>
								  <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                                <tr valign="baseline">
                                  <td colspan="3" align="center" valign="top" nowrap class="smalltext">
                                    <?php
//format content for preloading
if (!(isset($_POST["child_content_desc_ja"]))) {
	//$content = "here's the " . chr(13) . "\"preloaded <b>content</b>\"";
	$content = $row_sel['child_content_desc_ja'];
} else {
	//retrieve posted value
	$content = $_POST["child_content_desc_ja"];
}

// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// $oFCKeditor->BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
//$sBasePath = $_SERVER['PHP_SELF'] ;
//$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;

$oFCKeditor = new FCKeditor('child_content_desc_ja') ;
$oFCKeditor->BasePath	= "fckeditor/" ;
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
$oFCKeditor->Config['DefaultLanguage'] = 'ja' ;
$oFCKeditor->Height		= 700 ;
$oFCKeditor->Value		= $content ;
$oFCKeditor->Create() ;
?>									</td>
                                  </tr>
								  
                               <tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext" valign="top">Google Analytics&#12399;&#65306;</td>
                                  <td colspan="2"><textarea type="text" name="google_analytics_ja" rows="5" cols="62"><?=$_POST['google_analytics_ja']?$_POST['google_analytics_ja']:$row_sel['google_analytics']?></textarea></td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext">&#33879;&#32773;&#65306; </td>
                                  <td colspan="2"><input type="text" name="author_ja" value="<?php echo $_POST['author_ja']?$_POST['author_ja']:$row_sel['author_ja'];?>" size="32"></td>
                                </tr>
								<tr valign="baseline">
                                  <td align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  <td colspan="2">&nbsp;</td>
                                </tr>
                                <tr valign="baseline">
                                  <td align="left" nowrap class="smalltext">&#33879;&#20316;&#27177;&#65306; </td>
                                  <td colspan="2"><input type="text" name="copyright_ja" value="<?php echo $_POST['copyright_ja']?$_POST['copyright_ja']:$row_sel['copyright_ja'];?>" size="32"></td>
                                </tr>
								
                                <tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
</table></div></td></tr>
									
									<tr><td colspan="3" valign="middle"><div id="main_body_ajax_show_post_top" style="display:none; vertical-align:middle"><p align="center" class="allLink">Loading...</p><p align="center"><img src="<?=$path?>images/ajax_loader.gif" /></p></div></td></tr>
                                <tr valign="baseline">
                                  <td nowrap align="right">&nbsp;</td>
                                  <td colspan="2">
								  <input name="submit" type="submit" value="Save Page">
								  <input name="language" type="hidden" id="language" value="en">
             					  <input name="code" type="hidden" id="code" value="<?php echo $_REQUEST['code']?>" />
								  <input name="for" type="hidden" id="for" value="<?php echo $_REQUEST['for']?>" />
              					  <input name="new_page" type="hidden" id="code" value="<?php echo $_REQUEST['vu']?>" />			  </td>
                                </tr>
								<tr valign="baseline">
                                  <td colspan="3" align="left" valign="top" nowrap class="smalltext">&nbsp;</td>
                                  </tr>
                              </table><input type="hidden" name="MM_insert" value="form1"></form>
							<?php
							}
							?>							</td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
             </table></td>
      </tr>
     
              
              
            </table></td>
        <td background="<?=$path?>images/index_21.gif"><img src="<?=$path?>images/spacer.gif" width="46" height="100" /></td>
      </tr>
      <tr>
        <td><img src="<?=$path?>images/index_37.gif" width="46" height="48" alt="" /></td>
        <td background="<?=$path?>images/index-over_38.gif">&nbsp;</td>
        <td><img src="<?=$path?>images/index_40.gif" width="47" height="48" alt="" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><img src="<?=$path?>images/index_41.gif" width="987" height="52" alt="" /></td>
  </tr>
</table>
</body>
</html>
